package com.aofei.pangu.ui.welcome;

import android.arch.lifecycle.ViewModelProviders;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.aofei.pangu.BR;
import com.aofei.pangu.R;
import com.aofei.pangu.databinding.ActivityWelcomeBinding;
import com.aofei.pangu.ui.login.LoginActivity;

import me.goldze.mvvmhabit.base.BaseActivity;

public class WelcomeActivity extends BaseActivity<ActivityWelcomeBinding, WelcomeModel> {


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_welcome;

    }

    @Override
    public WelcomeModel initViewModel() {
        //View持有ViewModel的引用，如果没有特殊业务处理，这个方法可以不重写
        return ViewModelProviders.of(this).get(WelcomeModel.class);
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initViewObservable() {
        Handler handler = new Handler();
        //当计时结束,跳转至主界面
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(WelcomeActivity.this, LoginActivity.class);
                startActivity(intent);
                WelcomeActivity.this.finish();
            }
        }, 3000);
    }
}
